<meta charset="UTF-8" />
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
<link rel="stylesheet" href="/layui/css/layui.css" />

</head>
<form id="updatePwd" method="post">
	<input hidden="true" name="uid" th:value="${uid}" />
	<div class="layuiWindownContent">
		<div class="layui-form" lay-filter="indexUPdatePWFrom">
			<div class="layui-form-item">
				<label class="layui-form-label">原密码<font color="red">*</font>
				</label>
				<div class="layui-input-block">
					<input type="password" id="sysOldPWInp" name="sysOldPWInp"
						lay-verify="pass" placeholder="请填写原密码" autocomplete="off"
						class="layui-input" maxlength="14" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">新密码<font color="red">*</font>
				</label>
				<div class="layui-input-block">
					<input type="password" id="sysNewPWInp" name="sysNewPWInp"
						placeholder="请填写新密码" autocomplete="off" class="layui-input"
						maxlength="14" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">确认密码<font color="red">*</font>
				</label>
				<div class="layui-input-block">
					<input type="password" id="sysConfirmPWInp" name="sysConfirmPWInp"
						placeholder="请填写确认密码" autocomplete="off" class="layui-input"
						maxlength="14" />
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<button type="button" onclick="save()" class="layui-btn">立即提交</button>

				</div>
				<div class="layui-input-block">
					<button class="layui-btn" onclick="closehe()">取消</button>

				</div>
			</div>
		</div>
	</div>
</form>
<script type="text/javascript" src="/layui/layui.all.js"></script>
<script type="text/javascript" src="/layui/layui.js"></script>

<script type="text/javascript" src="/js/jquery/jquery-3.3.1.min.js"></script>
<script th:inline="javascript">
	/**
	 * 关闭此对话框
	 */
	closehe = function() {
		console.log("close");
		// var  inde=parent.layer.getFrameIndex(window.name);
		var index = parent.layer.getFrameIndex(window.name);
		console.log(index);
		parent.layer.close(index);
	};

	function save() {

		var sysOldPWInp = $("#sysOldPWInp").val();
		var sysNewPWInp = $("#sysNewPWInp").val();
		var sysConPW = $("#sysConfirmPWInp").val();
		if (sysOldPWInp == "") {

			layer.msg("原密码不能为空!");
			return false;
		}
		if (sysNewPWInp != sysConPW) {

			layer.msg("新密码和确认密码不一致!");
			return false;
		}
		$.ajax({
			url : "/user/updatePwd",
			//OrgSurvey.OrgSurveyData为一个对象
			data : {
				psw :sysOldPWInp ,npw : sysConPW
			},
			type : "post",
			async:false,
			success : function(data) {
				if (data == "success") {					
						 //当你在iframe页面关闭自身时
	 	         		    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	              			  //layer信息提示
	              		layer.msg("密码修改成功!");//下面是关键代码
		 	           	 setTimeout(function () { parent.layer.close(index) }, 330);//延迟
				} else {
					layer.msg(data);
				}
			}
		})

	};
</script>
</html>